﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace Core.Controllers
{
    public class SetupController : Controller
    {
        //
        // GET: /Setup/

        public ActionResult Index()
        {
            return View();
        }

        //
        // GET: /Setup/Reindex

        [Permission("Can Create/Delete Domain, Can Modify Domain")]
        public ActionResult Reindex()
        {
            return View();
        }

        //
        // POST: /Setup/Plugins/

        [HttpPost]
        [Permission("Can Create/Delete Domain, Can Modify Domain")]
        public JsonResult Plugins()
        {
            ContainerForReindex c = new ContainerForReindex();
            Models.CoreEntities core = new Models.CoreEntities();
            List<Models.Plugin> plugins = core.Plugins.Where(m => m.IsIndexedYN == "Y").OrderBy(m => m.Name).ToList();
            c.PluginCount = plugins.Count;
            foreach (Models.Plugin p in plugins)
            {
                c.Plugins.Add(new PluginInfoForReindex(p.Name, p.Area, p.AdminController, 0));
            }
            JsonResult r = Json(c);
            return r;
        }
    }
}
